<?php
session_start();
define('IN_SITE',true);
define('APP_ROOT', str_replace('\\','/',dirname(__FILE__)));
define('LIB_PATH', substr(APP_ROOT,0,-6) . '/lib/TinyCorePHP');
require LIB_PATH . '/TinyCorePHP.php';

$token = trim(getgpc('token'));
if($token){
	$uname = trim(getgpc('uname'));
	$pswd = trim(getgpc('pswd'));
	$user = M('User')->login($uname,$pswd);
	if($user['userid']){
		 $_SESSION['tiny']['LoginUser'] = array(
			'userid' => $user['userid'],
			'username' => $user['username'],
			'role' => $user['role'],
		 );
		 if($user['role'] == 0){
			redirect(C('backend'));
		 }
	}
	redirect(C('backend') . 'login.php?n='.time());
}
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Login</title>
<meta content='' name='description' />
<meta content='' name='author' />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="/admin/public/css/bootstrap.min.css" rel="stylesheet" >
<link href="/admin/public/css/jquery-ui-1.9.2.custom.css" rel="stylesheet" />
<link href="/admin/public/css/checkbox/grey.css" rel="stylesheet" />
<link href="/admin/public/css/font-awesome.min.css" rel="stylesheet" />
<!--[if lt IE 9]>
<link type="text/css" href="/admin/public/css/custom-theme/jquery.ui.1.9.2.ie.css"  rel="stylesheet" />
<![endif]-->

<link href="/admin/public/css/style.css" rel="stylesheet">
<script src="/admin/public/js/jquery.js"></script>
<script src="/admin/public/js/jquery.icheck.min.js"></script>

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="/admin/public/js/html5shiv.js"></script>
<script src="/admin/public/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
var upload_url = "/index.php/login/upload";
var del_url = "/index.php/file/del";
var _hmt = _hmt || [];
var app_path = "";
</script>
</head>
<body>
<!-- Wrap all page content here -->
<div class="container">
<div class="col-xs-12 Login">

<div class="container">
	<!-- /container -->
	<div class="row">
		<div class="col-xs-12 hidden-xs" style="margin-top:120px;"></div>
	</div>
	<div class="row">
		<div class="col-sm-8 hidden-xs">
			<div class="img" style="display:none;"></div>
		</div>
		<div class="col-sm-4 well">
			<div style="margin-bottom:44px">
				<h1 class="text-center">---------</h1>
			</div>
			<form action="" method="post" id="form_login" class="form-horizontal">
				<input type="hidden" name="token" value="<?php echo md5(time());?>" />
				<div class="form-group">
					<label class="col-sm-3  control-label" for="uname">帐号：</label>
					<div class="col-sm-9">
						<input class="form-control" id="uname"  name="uname"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3  control-label" for="pswd">密码：</label>
					<div class="col-sm-9">
						<input class="form-control" id="pswd" type="password" name="pswd"/>
					</div>
				</div>
				<div class="form-group display-none">
					<span class="col-sm-3  control-label" ></span>
					<div class="col-sm-9">
						<label class="inline pull-left col-3">
							<input class="ace" type="checkbox" name="id[]" value="" />
							<span class="lbl"></span></label><label for="remember-me" >记住我的登录状态</label>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-3 col-sm-9">
						<input type="button" value="登录" onclick="login();" class="btn btn-lg btn-primary">
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-8"></div>
		<div class="col-sm-4 text-right">
			<span>&copy;2014 <a href="www.lingshibao.cn" title="lingshibao.cn">www.lingshibao.cn</a></span>
		</div>
	</div>
	</div>
</div>
<script src="/admin/public/js/bootstrap.min.js"></script>
<script src="/admin/public/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="/admin/public/js/common.js"></script>
<script type="text/javascript">
function login() {
	$("#form_login").submit();
}

$(document).ready(function() {
	$("#pswd").keydown(function(event) {
		if (event.keyCode == 13) {
			login();
		}
	})
})
</script>

</body>
</html>